home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.1 / perldebug.1 < prev    next >
Text File  |  1995-07-25  |  11KB  |  265 lines

  1.  
  2.  
  3.  
  4.      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((RRRReeeelllleeeeaaaasssseeee 0000....0000 PPPPaaaattttcccchhhhlllleeeevvvveeeellll 00000000))))PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           perldebug - Perl debugging
  10.  
  11.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.           First of all, have you tried using the ----wwww switch?
  13.  
  14.           DDDDeeeebbbbuuuuggggggggiiiinnnngggg
  15.  
  16.           If you invoke Perl with a ----dddd switch, your script will be run
  17.           under the debugger.  However, the Perl debugger is not a
  18.           separate program as it is in a C environment.  Instead, the
  19.           ----dddd flag tells the compiler to insert source information into
  20.           the pseudocode it's about to hand to the interpreter.  (That
  21.           means your code must compile correctly for the debugger to
  22.           work on it.)  Then when the interpreter starts up, it pre-
  23.           loads a Perl library file containing the debugger itself.
  24.           The program will halt before the first executable statement
  25.           (but see below) and ask you for one of the following
  26.           commands:
  27.  
  28.           h           Prints out a help message.
  29.  
  30.           T           Stack trace.  If you do bizarre things to your
  31.                       @_ arguments in a subroutine, the stack
  32.                       backtrace will not always show the original
  33.                       values.
  34.  
  35.           s           Single step.  Executes until it reaches the
  36.                       beginning of another statement.
  37.  
  38.           n           Next.  Executes over subroutine calls, until it
  39.                       reaches the beginning of the next statement.
  40.  
  41.           f           Finish.  Executes statements until it has
  42.                       finished the current subroutine.
  43.  
  44.           c           Continue.  Executes until the next breakpoint is
  45.                       reached.
  46.  
  47.           c line      Continue to the specified line.  Inserts a one-
  48.                       time-only breakpoint at the specified line.
  49.  
  50.           <CR>        Repeat last n or s.
  51.  
  52.           l min+incr  List incr+1 lines starting at min.  If min is
  53.                       omitted, starts where last listing left off.  If
  54.                       incr is omitted, previous value of incr is used.
  55.  
  56.           l min-max   List lines in the indicated range.
  57.  
  58.           l line      List just the indicated line.
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 6/30/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((RRRReeeelllleeeeaaaasssseeee 0000....0000 PPPPaaaattttcccchhhhlllleeeevvvveeeellll 00000000))))PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  71.  
  72.  
  73.  
  74.           l           List next window.
  75.  
  76.           -           List previous window.
  77.  
  78.           w line      List window (a few lines worth of code) around
  79.                       line.
  80.  
  81.           l subname   List subroutine.  If it's a long subroutine it
  82.                       just lists the beginning.  Use "l" to list more.
  83.  
  84.           /pattern/   Regular expression search forward in the source
  85.                       code for pattern; the final / is optional.
  86.  
  87.           ?pattern?   Regular expression search backward in the source
  88.                       code for pattern; the final ? is optional.
  89.  
  90.           L           List lines that have breakpoints or actions.
  91.  
  92.           S           Lists the names of all subroutines.
  93.  
  94.           t           Toggle trace mode on or off.
  95.  
  96.           b line [ condition ]
  97.                       Set a breakpoint.  If line is omitted, sets a
  98.                       breakpoint on the line that is about to be
  99.                       executed.  If a condition is specified, it is
  100.                       evaluated each time the statement is reached and
  101.                       a breakpoint is taken only if the condition is
  102.                       true.  Breakpoints may only be set on lines that
  103.                       begin an executable statement.  Conditions don't
  104.                       use if:
  105.  
  106.                           b 237 $x > 30
  107.                           b 33 /pattern/i
  108.  
  109.  
  110.           b subname [ condition ]
  111.                       Set breakpoint at first executable line of
  112.                       subroutine.
  113.  
  114.           d line      Delete breakpoint.  If line is omitted, deletes
  115.                       the breakpoint on the line that is about to be
  116.                       executed.
  117.  
  118.           D           Delete all breakpoints.
  119.  
  120.           a line command
  121.                       Set an action for line.  A multiline command may
  122.                       be entered by backslashing the newlines.  This
  123.                       command is Perl code, not another debugger
  124.                       command.
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 6/30/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((RRRReeeelllleeeeaaaasssseeee 0000....0000 PPPPaaaattttcccchhhhlllleeeevvvveeeellll 00000000))))PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  137.  
  138.  
  139.  
  140.           A           Delete all line actions.
  141.  
  142.           < command   Set an action to happen before every debugger
  143.                       prompt.  A multiline command may be entered by
  144.                       backslashing the newlines.
  145.  
  146.           > command   Set an action to happen after the prompt when
  147.                       you've just given a command to return to
  148.                       executing the script.  A multiline command may
  149.                       be entered by backslashing the newlines.
  150.  
  151.           V package [symbols]
  152.                       Display all (or some) variables in package
  153.                       (defaulting to the main package) using a data
  154.                       pretty-printer (hashes show their keys and
  155.                       values so you see what's what, control
  156.                       characters are made printable, etc.).  Make sure
  157.                       you don't put the type specifier (like $) there,
  158.                       just the symbol names, like this:
  159.  
  160.                           V DB filename line
  161.  
  162.  
  163.           X [symbols] Same as as "V" command, but within the current
  164.                       package.
  165.  
  166.           ! number    Redo a debugging command.  If number is omitted,
  167.                       redoes the previous command.
  168.  
  169.           ! -number   Redo the command that was that many commands
  170.                       ago.
  171.  
  172.           H -number   Display last n commands.  Only commands longer
  173.                       than one character are listed.  If number is
  174.                       omitted, lists them all.
  175.  
  176.           q or ^D     Quit.  ("quit" doesn't work for this.)
  177.  
  178.           command     Execute command as a Perl statement.  A missing
  179.                       semicolon will be supplied.
  180.  
  181.           p expr      Same as print DB::OUT expr.  The DB::OUT
  182.                       filehandle is opened to /dev/tty, regardless of
  183.                       where STDOUT may be redirected to.
  184.  
  185.           Any command you type in that isn't recognized by the
  186.           debugger will be directly executed (eval'd) as Perl code.
  187.           Leading white space will cause the debugger to think it's
  188.           NOT a debugger command.
  189.  
  190.           If you have any compile-time executable statements (code
  191.           within a BEGIN block or a use statement), these will _N_O_T be
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 6/30/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((RRRReeeelllleeeeaaaasssseeee 0000....0000 PPPPaaaattttcccchhhhlllleeeevvvveeeellll 00000000))))PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  203.  
  204.  
  205.  
  206.           stopped by debugger, although requires will.  From your own
  207.           code, however, you can transfer control back to the debugger
  208.           using the following statement, which is harmless if the
  209.           debugger is not running:
  210.  
  211.               $DB::single = 1;
  212.  
  213.  
  214.           CCCCuuuussssttttoooommmmiiiizzzzaaaattttiiiioooonnnn
  215.  
  216.           If you want to modify the debugger, copy _p_e_r_l_5_d_b._p_l from the
  217.           Perl library to another name and modify it as necessary.
  218.           You'll also want to set environment variable PERL5DB to say
  219.           something like this:
  220.  
  221.               BEGIN { require "myperl5db.pl" }
  222.  
  223.           You can do some customization by setting up a ._p_e_r_l_d_b file
  224.           which contains initialization code.  For instance, you could
  225.           make aliases like these (the last one in particular most
  226.           people seem to expect to be there):
  227.  
  228.               $DB::alias{'len'} = 's/^len(.*)/p length($1)/';
  229.               $DB::alias{'stop'} = 's/^stop (at|in)/b/';
  230.               $DB::alias{'.'} = 's/^\./p '
  231.                               . '"\$DB::sub(\$DB::filename:\$DB::line):\t"'
  232.                               . ',\$DB::dbline[\$DB::line]/' ;
  233.  
  234.  
  235.           OOOOtttthhhheeeerrrr rrrreeeessssoooouuuurrrrcccceeeessss
  236.  
  237.           You did try the ----wwww switch, didn't you?
  238.  
  239.      BBBBUUUUGGGGSSSS
  240.           If your program _e_x_i_t()s or _d_i_e()s, so does the debugger.
  241.  
  242.           There's no builtin way to restart the debugger without
  243.           exiting and coming back into it.  You could use an alias
  244.           like this:
  245.  
  246.               $DB::alias{'rerun'} = 'exec "perl -d $DB::filename"';
  247.  
  248.           But you'd lose any pending breakpoint information, and that
  249.           might not be the right path, etc.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 6/30/95)
  262.  
  263.  
  264.  
  265.